package top.tenebrous.yzl.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.tenebrous.yzl.basic.model.CtsResult;
import top.tenebrous.yzl.service.IArchiveNoService;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("test")
@Slf4j
public class TestController {

    private static final List<String> areaCodes = new ArrayList<>();

    @Autowired
    private IArchiveNoService archiveNoService;

//    @PostConstruct
    public void initBitMap() {
        archiveNoService.initBitMap();
    }

    @RequestMapping("/init/{areaCode}")
    public CtsResult<String> init(@PathVariable("areaCode") String areaCode) {
        return archiveNoService.init(areaCode);
    }

    @RequestMapping("/getCode/{areaCode}")
    @Transactional(rollbackFor = Exception.class)
    public CtsResult<String> getCode(@PathVariable("areaCode") String areaCode) {
        return archiveNoService.getArchiveNo(areaCode);
    }

    @RequestMapping("/getNewCode/{areaCode}")
    @Transactional(rollbackFor = Exception.class)
    public CtsResult<String> getNewCode(@PathVariable("areaCode") String areaCode) {
        return archiveNoService.getNewArchiveNo(areaCode);
    }

    @RequestMapping("/generationCode")
    public CtsResult<Void> generationCode() {
        return archiveNoService.generationCode();
    }

}


















